﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace elctronixMVC.Models
{
    public class kategoriler
    {
        public int categoryID { get; set; }
        public string categoryname { get; set; }
        public string description { get; set; }



        public static List<kategoriler> categorigetir()
        {
            List<kategoriler> cat = new List<kategoriler>();
            SqlConnection sqlcon = connection.baglanti;
            SqlCommand sqlcmd = new SqlCommand("select * from categories", sqlcon);
            sqlcon.Open();
            SqlDataReader sdr = sqlcmd.ExecuteReader();
            while (sdr.Read())
            {
                kategoriler c = new kategoriler();
                c.categoryID = Convert.ToInt32(sdr["categoryID"]);
                c.categoryname = sdr["categoryname"].ToString();
                c.description = sdr["description"].ToString();
                cat.Add(c);
            }
            sqlcon.Close();
            return cat;
        }



    }
}